﻿/* ----------------------------------------------------------------------------
 * Copyright (c) Philip Stears 
 *
 * This source code is subject to terms and conditions of the Microsoft Public 
 * License (Ms-PL).
 * 
 * By using this source code in any fashion, you are agreeing to be bound 
 * by the terms of the Microsoft Public License.
 * 
 * To request a copy of the Microsoft Public License, send a request by email
 * to license@connectbasic.net.
 *
 * This notice must not be removed from this software.
 * ---------------------------------------------------------------------------- */

namespace ConnectBasic.ObjectModel
{
    using System.Collections.Generic;

    /// <summary>
    /// Represents a conditional block in an IF statement, e.g. the primary block, or one
    /// of the ElseIf blocks.
    /// </summary>
    public class ConditionalBlock : Block
    {
        private ExpressionBase mCondition;

        /// <summary>
        /// Initializes a new instance of the <see cref="ConditionalBlock" /> class.
        /// </summary>
        /// <param name="condition">The expression which decides whether the block gets executed or not.</param>
        /// <param name="statements">The statements which define the block.</param>
        public ConditionalBlock(ExpressionBase condition, IEnumerable<StatementNodeBase> statements) : base(statements)
        {
            mCondition = condition;
        }

        /// <summary>
        /// Gets the expression which decides whether the block gets executed or not.
        /// </summary>
        public ExpressionBase Condition
        {
            get { return mCondition; }
        }
    }
}
